package com.mitake.task.monthK;

import java.util.Map;

import com.mitake.parse.MonthK;
import com.mitake.parse.MonthK.MonthKItem;
import com.mitake.utils.Util;

public class MonthKCompareProcess {
	
	//public static ArrayList<MonthK[]> store =new ArrayList<MonthK[]>();
	
	public static MonthK[] data = null;
	
	 
	public static void compare(MonthK[] monthKs){
		for(int i = 1, len = monthKs.length-1; i<len; i++){
			compareItem(monthKs, monthKs[i].monthKMap, monthKs[i+1].monthKMap);
		}
		//store.add(monthKs);
		data = monthKs;
	}
	
	private static void compareItem(MonthK[] monthKs, Map<String,MonthKItem> monthK_1,Map<String,MonthKItem> monthK_2){
		for(String key : monthK_1.keySet()){
			 MonthKItem monthKItem = monthKs[0].monthKMap.get(key);
			 if(monthKItem == null){
				 monthKItem =new MonthKItem();
				 monthKs[0].monthKMap.put(key, monthKItem);
			 }
			if(Util.hasDifference(monthK_1.get(key).firstPrice, monthK_2.get(key).firstPrice)){
				monthKItem.lastPrice = "@";
			}
			if(Util.hasDifference(monthK_1.get(key).highPrice, monthK_2.get(key).highPrice)){
				monthKItem.lastPrice = "@";
			}
			if(Util.hasDifference(monthK_1.get(key).lowPrice, monthK_2.get(key).lowPrice)){
				monthKItem.lastPrice = "@";
			} 
			if(Util.hasDifference(monthK_1.get(key).lastPrice, monthK_2.get(key).lastPrice)){
				monthKItem.lastPrice = "@";
			}
			if(Util.hasDifference(monthK_1.get(key).volume, monthK_2.get(key).volume)){
				monthKItem.volume = "@";
			}
			if(Util.hasDifference(monthK_1.get(key).reference, monthK_2.get(key).reference)){
				monthKItem.volume = "@";
			}
		}
	}
}
